package com.minio.config;

import com.minio.pojo.MinioData;
import io.minio.MinioClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @auther LiZiBa
 * @date 2020/11/22 12:17
 * @description:
 **/

@Slf4j
@Configuration
public class MinioConfig {

    @Autowired
    private MinioData minioData;


    @Bean
    public MinioClient initMinioClient() {

        try{
            return new MinioClient(minioData.getUrl(), minioData.getAccessKey(), minioData.getSecretKey());
        }catch (Exception e) {
            log.error("初始化minio出现异常:{}", e.fillInStackTrace());
            throw new RuntimeException(e.fillInStackTrace());
        }
    }

}
